<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@page import="net.ideapad.data.Group"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>

<html>
	<head>
		<title>IdeaPad - Manage Group</title>
		<link rel="stylesheet" type="text/css" href="styles/main.css">
		<link rel="stylesheet" type="text/css" href="styles/buttons.css">
		<link rel="stylesheet" type="text/css" href="styles/currentbutton.css">
	</head>
	<body>
		<div class="header">
			<html:link action="/default">
				<img src="/IdeaPad/images/ideapad_logo.png" alt="logo" border="0" />
			</html:link>
			<%
				if (session.getAttribute("username") == null || session.getAttribute("username") == "") {
			%>
			<html:link page="/form/login.jsp" styleClass="menubuttons">Login</html:link>
			<html:link page="/form/registerUser.jsp" styleClass="menubuttons">Register</html:link>
			<%
				} else {
			%>
			Hello
			<%=session.getAttribute("username").toString()%>
			<html:link action="viewGroups" styleClass="menubuttons">Groups</html:link>
			<html:link action="manageGroups" styleClass="currentbutton">Manage Groups</html:link>
			<html:link page="/form/editUserSettings.jsp" styleClass="menubuttons">Settings</html:link>
			<html:link action="logout" styleClass="menubuttons">Logout</html:link>
			<%
				}
			%>
		</div>

		<logic:messagesPresent>
			<font color="red"> <logic:iterate name="Errors" id="Error"
					scope="request">
					<bean:write name="Error" />
					<br />
				</logic:iterate> </font>
		</logic:messagesPresent>

		<logic:notEmpty name="group" scope="request">
			<html:form action="/manageGroup"
				onsubmit="return validateMakeGuessForm(this)">
				<table border="1">
					<tr>
						<td>
							Property
						</td>
						<td>
							Current Value
						</td>
						<td>
							New Value
						</td>
					</tr>
					<tr>
						<td>
							Group ID
						</td>
						<td>
							<bean:write name="group" property="groupId" scope="request" />
						</td>
						<td>
							<html:hidden name="manageGroupForm" property="groupID"
								value="<%= ((Group) request.getAttribute("group")).getGroupId().toString() %>" />
						</td>
					</tr>
					<tr>
						<td>
							Group Name
						</td>
						<td>
							<bean:write name="group" property="groupName" />
						</td>
						<td>
							<html:text name="manageGroupForm" property="groupName" />
						</td>
					</tr>
					<tr>
						<td>
							Add User
						</td>
						<td>
							<html:link action="viewMembers">
								View Members
									<html:param name="groupID"
									value="<%= ((Group) request.getAttribute("group")).getGroupId().toString() %>" />
							</html:link>
						</td>
						<td>
							<html:text name="manageGroupForm" property="addUserIDString" />
						</td>
					</tr>
					<tr>
						<td>
							Remove User
						</td>
						<td></td>
						<td>
							<html:text name="manageGroupForm" property="removeUserIDString" />
						</td>
					</tr>
					<tr>
						<td>
							Add Moderator
						</td>
						<td>
							<html:link action="viewMembers">
								View Members
									<html:param name="groupID"
									value="<%= ((Group) request.getAttribute("group")).getGroupId().toString() %>" />
							</html:link>
						</td>
						<td>
							<html:text name="manageGroupForm" property="addModeratorIDString" />
						</td>
					</tr>
					<tr>
						<td>
							Remove Moderator
						</td>
						<td></td>
						<td>
							<html:text name="manageGroupForm"
								property="removeModeratorIDString" />
						</td>
					</tr>
				</table>

				<html:submit />
				<html:cancel />
			</html:form>
		</logic:notEmpty>
		<logic:empty name="group" scope="request">
			<logic:empty name="Errors">
				<font color="red">You do not have access to this group.</font>
			</logic:empty>
		</logic:empty>
	</body>
</html>

